package zhtt.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by zhaott on 2018/1/31.
 */
@Controller
public class MvcController {

    @Autowired
    private HttpServletRequest request;

    //①text/html ②application/xml ③application/json
    @RequestMapping(value="/",produces = "text/html; charset=utf-8")
    private @ResponseBody
    String home(){
        String cxf=request.getContextPath();
        String html="<a href='"+cxf+"'>home</a></br>";
        html+="<a href='"+cxf+"/welcome'>welcome</a></br>";
        html+="<a href='"+cxf+"/admin'>admin</a></br>";
        html+="<a href='"+cxf+"/db'>dba</a></br>";
        html+="<a href='"+cxf+"/zhtt/me'>/zhtt/me(需要权限认证的路径)</a></br>";
        return html;
    }

    @RequestMapping(value = { "/", "/home" }, method = RequestMethod.GET)
    public String homePage(ModelMap model) {
        model.addAttribute("greeting", "Hi, Welcome to mysite");
        return "welcome";
    }

}
